package com.ruoyi.pcj.service.impl;

import java.util.Arrays;
import java.util.List;

import com.mashuai.utils.base.MsEmptyUtils;
import com.mashuai.utils.toolkit.core.msMp.MsDb;
import com.mashuai.utils.toolkit.core.msValidation.annotation.MsCheckParams;
import com.ruoyi.basis.service.MsBaseServiceImpl;
import com.ruoyi.pcj.domain.PcjHobby;
import org.springframework.stereotype.Service;
import com.ruoyi.pcj.mapper.PcjTbPlatePartitionMapper;
import com.ruoyi.pcj.domain.PcjTbPlatePartition;
import com.ruoyi.pcj.service.IPcjTbPlatePartitionService;

/**
 * 贴吧-板块分区Service业务层处理
 * 
 * @author ms
 * @date 2024-02-27
 */
@Service
public class PcjTbPlatePartitionServiceImpl extends MsBaseServiceImpl<PcjTbPlatePartitionMapper,PcjTbPlatePartition> implements IPcjTbPlatePartitionService
{

    /**
     * 查询贴吧-板块分区
     * 
     * @param id 贴吧-板块分区主键
     * @return 贴吧-板块分区
     */
    @Override
    public PcjTbPlatePartition selectPcjTbPlatePartitionById(String id)
    {
        PcjTbPlatePartition entity=   MsDb.getById(id,PcjTbPlatePartition.class);
        return  entity;
    }

    /**
     * 查询贴吧-板块分区列表
     * 
     * @param pcjTbPlatePartition 贴吧-板块分区
     * @return 贴吧-板块分区
     */
    @MsCheckParams
    @Override
    public List<PcjTbPlatePartition> selectPcjTbPlatePartitionList(PcjTbPlatePartition pcjTbPlatePartition)
    {
        return baseMapper.selectPcjTbPlatePartitionList(pcjTbPlatePartition);
    }

    /**
     * 新增贴吧-板块分区
     * 
     * @param pcjTbPlatePartition 贴吧-板块分区
     * @return 结果
     */
    @Override
    public Boolean insertPcjTbPlatePartition(PcjTbPlatePartition pcjTbPlatePartition)
    {
        Boolean success = this.insertData(pcjTbPlatePartition);
        return  success;
    }

    /**
     * 修改贴吧-板块分区
     * 
     * @param pcjTbPlatePartition 贴吧-板块分区
     * @return 结果
     */
    @Override
    public Boolean updatePcjTbPlatePartition(PcjTbPlatePartition pcjTbPlatePartition)
    {
        Boolean success = this.updateData(pcjTbPlatePartition);
        return  success;
    }

    /**
     * 批量删除贴吧-板块分区
     * 
     * @param ids 需要删除的贴吧-板块分区主键
     * @return 结果
     */
    @Override
    public Boolean deletePcjTbPlatePartitionByIds(String[] ids)
    {
        Boolean success = this.removeBatchByIds(Arrays.asList(ids));
        return  success;

    }

    @Override
    public void batchSavePat(List<PcjTbPlatePartition> partitionList, String plateId) {
        //子表
        if (partitionList == null || partitionList.isEmpty()){
            return;
        }
        for (PcjTbPlatePartition partition : partitionList) {
            if (MsEmptyUtils.isNotEmpty(partition.getId())) {
                this.setDefFieldVal(partition, false);
            } else {
                partition.setPlateId(plateId);
                this.setDefFieldVal(partition, true);
            }
        }
        MsDb.saveOrUpdateBatch(partitionList);
    }


}
